package com.servlet;

import com.util.UtilJdbc;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import pom.Activity;

public class RightServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        UtilJdbc utilJdbc = new UtilJdbc();
        ResultSet set = utilJdbc.frist();
        ArrayList arrayList = new ArrayList();
        try {
            while (set.next()) {
                Activity activity = new Activity();

                activity.setActname(set.getString("actname"));
                activity.setPlanner(set.getString("planner"));
                activity.setActtime(set.getString("acttime"));
                activity.setActplace(set.getString("actplace"));
                activity.setActid(set.getInt("actid"));
                activity.setMember(set.getString("member"));
                arrayList.add(activity);
            }
            String aa=req.getParameter("name");
            req.setAttribute("a", arrayList);
            if (aa==null){
            req.getRequestDispatcher("/page/Right.jsp").forward(req,resp);}
            else {
            req.getRequestDispatcher("/page/ApplyRight.jsp").forward(req,resp);}
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }

    }
}
//req.getA(a)